<html>
<head>
<title>Add 活動</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link media="all" href="/cms/css/cms.min.css" type="text/css" rel="stylesheet" /> 
<link rel="stylesheet" type="text/css" href="/cms/css/tag/token-input.css" />
<script  type="text/javascript" src="/cms/js/cms.1.1.min.js"></script>
<script type="text/javascript" src="/cms/js/tag/jquery.tokeninput.js"></script> 
<script language="JavaScript" src="/cms/js/cleditor/jquery.cleditor.min.js"></script>
<script language="JavaScript" src="/cms/js/jquery.validate.js"></script>
<script language="JavaScript" src="/cms/js/autocomplete/textarea.js"></script>

</head>

<body>
{#include file="$navigation"#}
<div style="float:right;" id="login"></div>

<script>
$(document).ready(function() {	

});	
  function validate_form(form){
	  if (validator.form())  form.submit(); else alert('Some fields has error. Please check and resubmit');
  }
</script>

<H1><span id="parent_key_label"></span>活動</H1>
<form name="form_showadd" method="post" id="form_showadd" action="{#$self_url#}" >	
<div class='tableWrapper' style="width:100%;margin:0;padding:0;">
  <div class='tableHeader' >

	<ul class="tableActions">
  <li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="Submit" value=" 儲存 " onclick="form.subaction.value='edit_after_add'; form.submit();" type="button"></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" type="submit" name="Submit" value=" 確定 "></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="Submit" value=" 儲存並新增 " onclick="form.subaction.value='showadd_after_add'; form.submit();" type="button"></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="dummy" value=" 取消 " size="3" onclick="javascript:window.location.href='{#$self_url#}/list'" type="button"></li>
	</ul>

  <div class='clear'></div>
  <div class='corner left'></div>
  <div class='corner right'></div>
  </div>	
<table border="0" cellspacing='0' >

<tr id="tr_title"><td><B>標題</B></td>
<td id="td_title"><input id="field_title" type="text" name="title" value=""></td></tr>
<tr id="tr_starttime"><td><B>開始時間</B></td>
<td id="td_starttime"><input type="text" name="starttime" value="{#$showadd_data.starttime#}" id="datepicker_starttime">
<script type="text/javascript">  
$(function() {  
    $('#datepicker_starttime').datepicker({  
        duration: '',  
        showTime: true,  
        constrainInput: false,  
        stepMinutes: 1,  
        stepHours: 1,          
        altTimeField: '',  
        dateFormat:'yy-mm-dd',
        time24h: true  
     });  
});  
</script>

</td></tr>
<tr id="tr_endtime"><td><B>結束時間</B></td>
<td id="td_endtime"><input type="text" name="endtime" value="{#$showadd_data.endtime#}" id="datepicker_endtime">
<script type="text/javascript">  
$(function() {  
    $('#datepicker_endtime').datepicker({  
        duration: '',  
        showTime: true,  
        constrainInput: false,  
        stepMinutes: 1,  
        stepHours: 1,          
        altTimeField: '',  
        dateFormat:'yy-mm-dd',
        time24h: true  
     });  
});  
</script>

</td></tr>
<tr id="tr_event_type"><td><B>分類</B></td>
<td id="td_event_type">{#$showadd_data.event_type#}</td></tr>
<tr id="tr_event_date_row_separator" style="background:#F5F5F5;"><td colspan="2" style="font-weight:bold;text-align:center;">活動日期及地點</td></tr>

<tr id="tr_event_date"><td><B>活動日期</B></td>
<td id="td_event_date"><input type="text" name="event_date" value="{#$showadd_data.event_date#}" id="datepicker_event_date">
<script type="text/javascript">
	$(function() {
		$("#datepicker_event_date").datepicker(
		{dateFormat: 'yy-mm-dd', 
		    numberOfMonths: 2,
		    showOtherMonths: true, selectOtherMonths: true,
			changeMonth: true, changeYear: true,  
            showWeek: true,			
			showButtonPanel: true
          }
		);
	});
</script>
</td></tr>
<tr id="tr_event_time"><td><B>時間</B></td>
<td id="td_event_time"><input id="field_event_time" type="text" name="event_time" value=""></td></tr>
<tr id="tr_place"><td><B>地點</B></td>
<td id="td_place"><input id="field_place" type="text" name="place" size="80" value=""></td></tr>
<tr id="tr_event_url"><td><B>url</B></td>
<td id="td_event_url"><input id="field_event_url" type="text" name="event_url" size="80" value=""></td></tr>
<tr id="tr_intro"><td><B>簡介</B></td>
<td id="td_intro"><textarea id="field_intro" name="intro" cols="80" rows="4"></textarea></td></tr>
<tr id="tr_has_detail"><td><B>已有活動報導</B></td>
<td id="td_has_detail">{#$showadd_data.has_detail#}&nbsp;&nbsp;活動報導相片，請按 "PHOTO" 輸入。 </td></tr>
<tr id="tr_body"><td><B>活動報導詳細內容</B></td>
<td id="td_body"><textarea id="field_body" name="body" cols="80" rows="10"></textarea></td></tr>
<tr id="tr_product"><td><B>產品id</B></td>
<td id="td_product"><input id="field_product" type="text" name="product" value=""><BR/>產品id， 請以 “,” 分開<BR/>（註： 暫時請輸入以ID 輸入，之後會修改）</td></tr>
<tr id="tr_brand_str"><td><B>品牌名稱</B></td>
<td id="td_brand_str"><input id="field_brand_str" type="text" name="brand_str" size="80" value=""></td></tr>
<tr id="tr_member_type"><td><B>member_type</B></td>
<td id="td_member_type">{#$showadd_data.member_type#}</td></tr>
<tr id="tr_points"><td><B>points</B></td>
<td id="td_points">{#$showadd_data.points#}</td></tr>
<tr id="tr_click"><td><B>人氣</B></td>
<td id="td_click"><input id="field_click" type="text" name="click" value=""></td></tr>
<tr id="tr_likes"><td><B>likes</B></td>
<td id="td_likes"><input id="field_likes" type="text" name="likes" value=""></td></tr>
<tr id="tr_quota"><td><B>名額</B></td>
<td id="td_quota"><input id="field_quota" type="text" name="quota" value=""></td></tr>
<tr id="tr_apply_num"><td><B>申請人數</B></td>
<td id="td_apply_num"><input id="field_apply_num" type="text" name="apply_num" value=""></td></tr>
<tr id="tr_video"><td><B>video</B></td>
<td id="td_video"><input id="field_video" type="text" name="video" size="80" value=""></td></tr>
<tr id="tr_video_details"><td><B>video_details</B></td>
<td id="td_video_details"><textarea id="field_video_details" name="video_details" cols="60" rows="4"></textarea></td></tr>
<tr id="tr_terms"><td><B>條款</B></td>
<td id="td_terms"><textarea id="field_terms" name="terms" cols="80" rows="6"></textarea></td></tr>
<tr id="tr_status"><td><B>上線狀態</B></td>
<td id="td_status">{#$showadd_data.status#}</td></tr>

  <tr>
    <td>&nbsp;</td>
    <td>
     	
    <input type="hidden" name="action" value="add"><input name="subaction" type="hidden">
     <ul class="tableActions">
    <li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="Submit" value=" 儲存 " onclick="form.subaction.value='edit_after_add'; form.submit();" type="button"></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" type="submit" name="Submit" value=" 確定 "></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="Submit" value=" 儲存並新增 " onclick="form.subaction.value='showadd_after_add'; form.submit();" type="button"></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="dummy" value=" 取消 " size="3" onclick="javascript:window.location.href='{#$self_url#}/list'" type="button"></li>
    </ul>
  </td>
  </tr>
</table>

</form>

<script type="text/javascript"> 	
$(function(){
  $(".tips").tipTip({defaultPosition: "right", edgeOffset: 10});
}); 
</script>

<script type="text/javascript">
//$(function(){
//});

//$(document).ready(function() {	
//});
</script>

<script type="text/javascript">

/*
function hidden_rows_by_type(type){

  var myArray = [
    ['n_coming_issue'], // group 2
    [ 'fix_issue'] ,  // group 1
  ];

  for (var i=0; i<myArray.length; i++) {
    if (type == i + 1){
       for (var j=0; j<myArray[i].length; j++){
         $('#tr_'+myArray[i][j]).show();
       }
    } else {
       for (var j=0; j<myArray[i].length; j++){
        $('#tr_'+myArray[i][j]).hide();
       }
    }
  }
}

$(document).ready(function() {	
	var type = parseInt($('[name|="type"]').val());
	hidden_rows_by_type(type);

	$('[name|="type"]').change(function() {
		hidden_rows_by_type(parseInt($(this).val()));
	});

});
*/

$(document).ready(function() {	
	var now = new Date();

	if ($('#datepicker_starttime').val() == ''){
		var start = now.getFullYear() + '-' + parseInt(now.getMonth()+1) + '-' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes();
		$('#datepicker_starttime').val(start);
	}
	
	if ($('#datepicker_endtime').val() == ''){
		now.setMonth( now.getMonth( ) + 1 );
		var end = now.getFullYear() + '-' + parseInt(now.getMonth()+1) + '-' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes();
		$('#datepicker_endtime').val(end);
	}
});
</script><script type="text/javascript">

function hidden_rows_by_type(type){

  var myArray = [
    [] ,   // show when value = 0
    ['body','content_json','bloggers'],  // show when value = 1
  ];

  for (var i=0; i<myArray.length; i++) {
    if (type == i){
       for (var j=0; j<myArray[i].length; j++){
         $('#tr_'+myArray[i][j]).show();
       }
    } else {
       for (var j=0; j<myArray[i].length; j++){
        $('#tr_'+myArray[i][j]).hide();
       }
    }
  }
}

$(document).ready(function() {	
	var type = parseInt($('[name|="has_detail"]').val());
	hidden_rows_by_type(type);

	$('[name|="has_detail"]').change(function() {
		hidden_rows_by_type(parseInt($(this).val()));
	});

});

</script> 
<!--POSTRUNJS-->
</body>
</html>
